package com.som.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.som.bean.data4.input.SzCityIpAddressinfo;
import com.som.console.ExcelProcException;
import com.som.console.PathEnum;
import com.som.service.ExcelDataServiceInf;
import com.som.service.excel.FileReadProcess;
import com.som.service.excel.FileWriteProcess;
import com.som.service.excel.data4.input.StateIpAddressInfoFileRead;
import com.som.service.excel.data4.input.SzCityIpAddressinfoFileRead;

/**
 * 苏州地市数据处理
 * 
 * @author liujun
 * @date 2016年4月8日
 * @verion 0.0.1
 */
public class FileData4ServiceImpl implements ExcelDataServiceInf {

	/**
	 * 苏州地市数据读取
	 */
	private FileReadProcess<String, SzCityIpAddressinfo> szCityread = new SzCityIpAddressinfoFileRead();

	/**
	 * 全省数据1读取
	 */
	private FileReadProcess<String, String> stateIp1read = new StateIpAddressInfoFileRead();

	/**
	 * 进行数据写入操作
	 */
	private FileWriteProcess write = new FileWriteProcess();

	public boolean excelDataProcess(Map<String, String> pathMap) throws ExcelProcException {
		// 最终的结果信息
		List<String> resultList = new ArrayList<String>();
		// 苏州地市的IP信息
		List<String> cityList = new ArrayList<String>();

		// 1,读取苏州的地市数据
		szCityread.readExcelDataMap(pathMap.get(PathEnum.DATA4_INPUT_FILE_3_FLAG.getPathFlag()), false, resultList, cityList);

		// 读取全省的地市数据1
		stateIp1read.readExcelDataMap(pathMap.get(PathEnum.DATA4_INPUT_FILE_1_FLAG.getPathFlag()), true, resultList, cityList);
		// 读取全省的地市数据2
		stateIp1read.readExcelDataMap(pathMap.get(PathEnum.DATA4_INPUT_FILE_2_FLAG.getPathFlag()), true, resultList, cityList);

		// 转换完成之后进行数据输出
		write.writeByList(pathMap.get(PathEnum.DATA4_OUTPUT_FILE_FLAG.getPathFlag()), resultList);

		return true;
	}

}
